package com.dyz.swordFingerOffer;

import java.util.ArrayList;

/**
 * @author: daiyizheng
 * @date: 2021/6/12 1:07
 * @description:
 */
public class maxInWindows59 {
    public static void main(String[] args) {
        int[] arr = new int[]{2,3,4,2,6,2,5,1};
        new maxInWindows59().maxInWindows(arr, 3);
    }
    public ArrayList<Integer> maxInWindows(int [] num, int size) {
        ArrayList<Integer> arr = new ArrayList<>();
        if(num==null||num.length==0||size<=0||num.length<size){
            return arr;
        }

        int left = 0;
        int right = size-1;
        while(right<=num.length-1){
            Integer max = Integer.MIN_VALUE;
            for(int i=left; i<=right; i++){
                if(num[i]>max){
                    max = num[i];
                }
            }
            arr.add(max);
            left++;
            right++;
        }
        return arr;
    }
}
